import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from '@vant/auto-import-resolver'
import AutoImport from 'unplugin-auto-import/vite'
import postcssPxtorem from 'postcss-pxtorem'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [VantResolver()],
    }),
    Components({
      resolvers: [VantResolver()],
    }),
  ],
  css: {
    postcss: {
      plugins: [
        postcssPxtorem({
          rootValue: 37.5, // 设计稿宽度的1/10
          propList: ['*'], // 需要转换的属性，这里选择全部都进行转换
          selectorBlackList: ['van-'], // 过滤掉.van-开头的class，不进行rem转换
        })
      ]
    }
  },
  server: {
    host: '0.0.0.0',
    port: 3000,
    proxy: {
      // 配置API代理
      '/appointment': {
        target: 'http://8.130.122.210:8081',
        changeOrigin: true,
        rewrite: (path) => path
      },
      // '/user': {
      //   target: 'http://8.130.122.210:8081',
      //   changeOrigin: true,
      //   rewrite: (path) => path
      // },
      // '/wechat': {
      //   target: 'http://8.130.122.210:8081',
      //   changeOrigin: true,
      //   rewrite: (path) => path
      // },
      // '/weighing': {
      //   target: 'http://8.130.122.210:8081',
      //   changeOrigin: true,
      //   rewrite: (path) => path
      // }
    }
  }
})